package map.android.baidu.carpool.data.impl;

import android.content.Context;
import android.text.TextUtils;
import map.android.baidu.carpool.WebConfig;
import map.android.baidu.carpool.data.CarpoolBaseData;
import map.android.baidu.carpool.response.MainConfigResponse;
import map.android.baidu.carpool.setting.UserInfoSetting;

import java.util.HashMap;
import java.util.Map;

/**
 * Created by zhangtongyu on 15/3/25.
 * main模块config基础配置接口request
 */
public class MainConfigData extends CarpoolBaseData<MainConfigResponse>{

    private String cityCode;
    private String cache;
    public MainConfigData(Context context) {
        super(context);
    }

    public void setCityCode(String cityCode) {
        if(!TextUtils.isEmpty(cityCode)) {
            this.cityCode = cityCode;
        } else {
            this.cityCode = UserInfoSetting.getCityId();
        }
    }

    public void setCache(String cache) {
        this.cache = cache;
    }

    @Override
    protected String getUrl() {
        return WebConfig.getUrl(WebConfig.URL_ID_CONFIG);
    }

    @Override
    protected Map<String, String> getParams() {

        Map<String , String> params = new HashMap<String, String>();
        params.put("cityCode" , cityCode);
        params.put("cache" , cache);
        return params;
    }
}
